<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/adminjsp/taglibs.jsp"%>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>人人自由任务后台管理系统</title>
		<link rel="stylesheet" href="../../styles/adminCss/backstage.css">
		<script type="text/javascript" src="../../javascript/adminJs/jquery.min.js"></script>
		<script type="text/javascript" src="../../javascript/adminJs/jquery.easydrag.handler.beta2.js"></script>
	</head>
	<script type="text/javascript">
		function get(id){
			var obj = document.getElementById(id);
			return obj;
		}
		function addBoxShow(config){
			if(config == 1){
				get("addBox").style.display = "block";
			}else{
				get("addBox").style.display = "none";
			}
		}
		function saveCate(thisform){
			if(get("addCategory").value == "" || get("addCategory").value == null){
				alert("分类名不能为空");
				return false;
			}
			
		};
		
		function popBox(id){
			$.get("/adminjsp/updateCategory?cateId="+id,function(data){
				$("#popBox1").html(data);
			});
		}
		function editBoxShow(config){
			if(config == 1){
				$("editCateBox").style.display = "block";
			}else{
				$("editCateBox").style.display = "none";
			}
		}
	</script>
	<body>
		<div id="popBox1" style="width:100%;"></div>
		<jsp:include page="top.jsp"></jsp:include>
		<div class="adminMain">
			<div class="adminLeft">
				<jsp:include page="left.jsp"></jsp:include>
			</div>
			<div class="adminRight">
			    <div class="content clearfix">
			        <div class="main">
			            <!--右侧内容-->
						<div class="cont">
			                <div class="title">任务分类</div>
			                <div class="details">
			                <form onsubmit="return saveCate(this)"  method="post" action="saveCate" >
			                    <div class="details_operation clearfix">
			                        <div id="addButton" class="bui_select">
			                            <input onclick="addBoxShow(1)" type="button" value="添&nbsp;&nbsp;加" class="add">
			                        </div>
			                        
			                        <div id="addBox" class="addCategorybox">
			                        	分类名：<input id="addCategory" name="addCategoty" type="text" >
			                        			<input id="saveCategory" type="submit" value="保存">
			                        			<input onclick="addBoxShow(0)" id="reset" type="button" value="取消">
			                        </div>
			                    </div>
			                     </form>
			                    <!--表格-->
			                    <table class="table" cellspacing="0" cellpadding="0">
			                        <thead>
			                            <tr>
			                                <th width="15%">类别编号</th>
			                                <th width="40%">类别名称</th>
			                                <th width="40%">操作</th>
			                            </tr>
			                        </thead>
			                        <tbody>
			                        	<c:forEach var="data" items="${cateInfoList}" varStatus="status">
			                            <tr>
			                                <!--这里的id和for里面的c1 需要循环出来-->
			                                <td><input type="checkbox" id="c1" class="check"><label for="c1" class="label">${data.cateId}</label></td>
			                                <td>${data.cateName}</td>
			                                <td align="center"><a onclick="popBox(${data.cateId})" name="updateCategory" id="updateCategory" class="btn">修改</a>
			                                <a href="deleteCategory?cateId=${data.cateId}" class="btn" onClick="return window.confirm('确认要删除选中的信息')">删除</a>
			                            </tr>
			                          </c:forEach>  
			                        </tbody>
			                    </table>
			                </div>
            			</div>

			        </div>
			    </div>
	        </div>
	    </div>
	</body>
</html>